<template>
    <div v-if="contentText" v-loading="loading" class="data-content">
        <el-descriptions class="margin-top" title="相关信息" :column="2" border>
            <template slot="extra">
                <el-link class="top-font"  :underline="false" type="warning" @click="downLoad">下载严重违法记录界面截图</el-link>
            </template>
            <el-descriptions-item>
                <template slot="label"> 企业名称 </template>
                {{ contentText.qymc }}
            </el-descriptions-item>

            <el-descriptions-item>
                <template slot="label">
                    统一社会信用代码
                </template>
                {{ contentText.tyshxydm }}
            </el-descriptions-item>

            <el-descriptions-item>
                <template slot="label">
                   企业地址
                </template>
                {{ contentText.qydz }}
            </el-descriptions-item>

            <el-descriptions-item>
                <template slot="label">
                    严重违法失信行为的具体情形
                </template>
                {{ contentText.jtqx }}
            </el-descriptions-item>

            <el-descriptions-item>
                <template slot="label">
                   处罚结果
                </template>
                {{ contentText.cfjg }}
            </el-descriptions-item>
            
            <el-descriptions-item>
                <template slot="label">
                   处罚依据
                </template>
                {{ contentText.cfyj }}
            </el-descriptions-item>

            <el-descriptions-item>
                <template slot="label">
                  公布日期
                </template>
                 {{ contentText.gbrq }}
            </el-descriptions-item>

            <el-descriptions-item>
                <template slot="label">
                   处罚日期
                </template>
                {{ contentText.cfrq }}
            </el-descriptions-item>

            <el-descriptions-item>
                <template slot="label">
                  公布截止日期
                </template>
                {{ contentText.gbjzrq }}
            </el-descriptions-item>

            <el-descriptions-item>
                <template slot="label">
                   执法单位
                </template>
                {{ contentText.zfdw }}
            </el-descriptions-item>
        </el-descriptions>
         <el-link v-if="contentText" type="info" :underline="false">*此数据来源于中国政府采购网</el-link>
    </div>
    <div v-else>
        <div class="nodata">
            <img :src="imgUrl" alt="" />
        </div>
    </div>
</template>

<script>
export default {
    props: {
        companyName: {
            type: String,
            default: "",
        },
        projectId: {
            type: String,
            default: "",
        },
        taxNumber: {
            type: String,
            default: "",
        },
        navName: {
            type: String,
            default: "",
        },
    },
    data: () => ({
        contentText: {},
        imgUrl: require("../../img/wu.png"),
        loading:false
    }),
    methods: {
        //获取企业基本信息
        getQiYeInfo() {
            var that = this;
            this.loading = true
            this.$ajax({
                type: "get",
                url: `${this.$store.state.api.searchUrl}/searchzhengcai/zhengcai/dishonesty`,
                data: {
                    corpName: that.palindrome(that.companyName),
                    projectId: that.projectId,
                    pagNo: 1,
                },
                callback: function (data, res) {
                    if (data && data.length > 0) {
                        console.log("12312312312321");
                        that.contentText = data[0];
                        that.$emit('pushValidNames',that.navName)
                    } else if (data.code == 401006) {
                        ShowMsg("无查询功能VIP服务或VIP服务已过期", "info");
                    }
                    that.loading = false
                },
            });
        },
        /**
         * 下载截图
         */
        downLoad(){
            var search = toSearch({
                type:"yzwfjl",
                id:this.contentText.id,
                corpName: this.companyName,
                tyshxydm: this.taxNumber,
            });

            this.loading = true;
            setTimeout(() => {
                this.loading = false
            }, 5000);

            window.location.href = `${this.$store.state.api.searchUrl}/searchcreditchina/downloadimage${search}`; 
        },
        /**
         * 去除符号（除了小括号）
         * @param {String} str 待处理的字符串
         */
        palindrome(str) {
            let res = str.replace(/[`:_.~!@#$%^&* \+ =<>?"{}|, \/ ;' \\ [ \] ·~！@#￥%……&*—— \+ ={}|《》？：“”【】、；‘’，。、]/g,'');
            return res
        }

    },
    watch: {
        companyName() {
            this.getQiYeInfo();
        },
    },
    mounted() {
        this.getQiYeInfo();
    },
};
</script>

<style scoped lang="scss">
.top-font {
    display: block;
    margin: 3px 0px;
    float: right;
    color: #fd8320;
}
.top-font:hover {
    color: #fd8320b0;
}
::v-deep .el-link.el-link--warning.is-disabled {
        color: #f5a86a;
    }
.data-content {
    // border-bottom: 1px solid #efefef;
    padding: 10px 15px;
}
.nodata {
    width: 30%;
    margin: 20px auto;
}
</style>
